import { Component, OnInit, Input } from '@angular/core';
import { Response } from '@angular/http';

import { TopbarserveService } from './topbarserve.service';



@Component({
  selector: 'app-topbar',
  templateUrl: './topbar.component.html',
  styleUrls: ['./topbar.component.less']
})
export class TopbarComponent implements OnInit {
   data;
   location: [{id: number, name: string}];
   userCenter;
  constructor(private topbarServeService: TopbarserveService) { }
  getData() {
    this.topbarServeService.getServe()
    .subscribe(
      (response: Response) => {
        const data = response.json();
        // console.log(data);
        this.data = data.data;
        this.location = data.data.topMenu.left;
        this.userCenter = data.data.right;
      },
      (errors) => {
        console.log(errors);
      }
    );
  }
  ngOnInit() {
    this.getData();
  }

}
